package com.smfx.yxt.controller.sys;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.smfx.yxt.common.enums.ExcelTemplate;
import com.smfx.yxt.controller.BaseController;
import com.smfx.yxt.excel.JxlsExcelView;
import com.smfx.yxt.model.Grid;
import com.smfx.yxt.page.OrderBy;
import com.smfx.yxt.page.Page;
import com.smfx.yxt.reqVo.StudentReqVO;
import com.smfx.yxt.service.IParentService;
import com.smfx.yxt.view.ParentPersonImportView;

@RequestMapping("sys/parent/manage")
@Controller
public class SysParentManageController extends BaseController {

	private Logger logger = LoggerFactory.getLogger(getClass());
	
	@Autowired
	private IParentService parentService;
	
	@RequestMapping("")
	public String index() {
		return "sys/parentManage";
	}
	
	@RequestMapping("json/parentList")
	@ResponseBody Object studentList(StudentReqVO vo) {
		try {
			Grid grid = new Grid();
			Page<ParentPersonImportView> page = new Page<>();
			page.setParams(vo);
			page.setPageNo(vo.getPage());
			page.setPageSize(vo.getRows());
			List<OrderBy> sorts = new ArrayList<>();
			sorts.add(new OrderBy("grade"));
			sorts.add(new OrderBy("clazz"));
			page.setSorts(sorts);
			List<ParentPersonImportView> list = parentService.selectPersonImport(page);
			grid.setRows(list);
			grid.setTotal(page.getTotalRecord());
			return grid;
		} catch (Exception e) {
			logger.error("---studentList error={}", e);
		}
		return null;
	}
	
}
